<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
	<meta charset="utf-8" />
		<title>调账商务审核</title>		
		
			<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/ext-all-debug.js"></script>
<script type="text/javascript" src="static/js/jquery-1.7.2.js" />
			<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/locale/ext-lang-zh_CN.js"></script>
			<link rel="stylesheet" href="plugins/websocketInstantMsg/ext4/resources/css/ext-all.css" />
			
			
</head>
<body>

</body>
<script type="text/javascript">
Ext.onReady(function(){
	var store = Ext.create('Ext.data.Store', {
		fields: [	"ID",
		         	"COST_ID",
		         	"COST_PLATE",
		         	"BILL_CODE",
		        	"LADING_BILL_CODE",
// 		        	"BILL_TYPE",
		        	"SETTLEMENT_UNIT",
		        	"COST_NAME",
		        	"CONTAINER_TYPE",
		        	"TAX_PRICE",
		        	"ADJUST_TAX_PRICE",
		        	"NON_TAX_PRICE",
		        	"ADJUST_NON_TAX_PRICE",
		        	"TAX_RATE",
		        	"ADJUST_TAX_RATE",
		        	"CONTAINER_NUM",
		        /* 	"ADJUST_TAX_RATE", */
		        	"CURRENCY"],
		pageSize: 25,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>account/settlementInfo',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				 root: 'result.list',  //数据
	                totalProperty: 'result.total' //数据总条数
			}
		},
		autoLoad: true
	});
	 var edit =new Ext.Button({
		 text: '审批通过',
	     	listeners: {
	         'click': function () {
		 var records = grid.getSelectionModel().getSelection();
    	 if(records.length==0){
       			Ext.Msg.alert("提示","请至少选择一条记录");return;
       		}
    	 
    	 var arr = [];
			Ext.each(records,function(item){
				obj = {
						ID:item.data.ID,
						COST_ID:item.data.COST_ID,
						COST_PLATE:item.data.COST_PLATE,
						BILL_CODE:item.data.BILL_CODE,
						LADING_BILL_CODE:item.data.LADING_BILL_CODE,
						SETTLEMENT_UNIT:item.data.SETTLEMENT_UNIT,
						COST_NAME:item.data.COST_NAME,
						CONTAINER_TYPE:item.data.CONTAINER_TYPE,
						TAX_PRICE:item.data.TAX_PRICE,
						ADJUST_TAX_PRICE:item.data.ADJUST_TAX_PRICE,
						NON_TAX_PRICE:item.data.NON_TAX_PRICE,
						ADJUST_NON_TAX_PRICE:item.data.ADJUST_NON_TAX_PRICE,
						TAX_RATE:item.data.TAX_RATE,
						ADJUST_TAX_RATE:item.data.ADJUST_TAX_RATE,
						CONTAINER_NUM:item.data.CONTAINER_NUM,
					/* 	ADJUST_TAX_RATE:item.data.ADJUST_TAX_RATE, */
						CURRENCY:item.data.CURRENCY,
				};
				arr.push(obj);
			});
			var array = JSON.stringify(arr);
    				
    					Ext.Ajax.request({
    						url:'<%=basePath%>account/saveFeeInfo',
    						params:{
    							array:array
    						},
    						timeout:5000,
    						success:function(response){
    							store.load();
    							Ext.Msg.alert("成功","审批通过!");
    						},
    						failure:function(response){
    							store.load();
    							Ext.Msg.alert("成功","审批通过!");
    						}
    					});
    				

    	 
    	 }
	     	}
	 });
	 
	 
	 var NoPass =new Ext.Button({
		 text: '审批不通过',
	     	listeners: {
	         'click': function () {
		 var records = grid.getSelectionModel().getSelection();
    	 if(records.length==0){
       			Ext.Msg.alert("提示","请至少选择一条记录");return;
       		}
    	 var arr = [];
			Ext.each(records,function(item){
				obj = {
						ID:item.data.ID,
						COST_ID:item.data.COST_ID,
						COST_PLATE:item.data.COST_PLATE,
						BILL_CODE:item.data.BILL_CODE,
						LADING_BILL_CODE:item.data.LADING_BILL_CODE,
						SETTLEMENT_UNIT:item.data.SETTLEMENT_UNIT,
						COST_NAME:item.data.COST_NAME,
						CONTAINER_TYPE:item.data.CONTAINER_TYPE,
						TAX_PRICE:item.data.TAX_PRICE,
						ADJUST_TAX_PRICE:item.data.ADJUST_TAX_PRICE,
						NON_TAX_PRICE:item.data.NON_TAX_PRICE,
						ADJUST_NON_TAX_PRICE:item.data.ADJUST_NON_TAX_PRICE,
						TAX_RATE:item.data.TAX_RATE,
						ADJUST_TAX_RATE:item.data.ADJUST_TAX_RATE,
						CONTAINER_NUM:item.data.CONTAINER_NUM,
					/* 	ADJUST_TAX_RATE:item.data.ADJUST_TAX_RATE, */
						CURRENCY:item.data.CURRENCY,
				};
				arr.push(obj);
			});
			var array = JSON.stringify(arr);
    				
    					Ext.Ajax.request({
    						url:'<%=basePath%>account/NoPass',
    						params:{
    							array:array
    						},
    						timeout:5000,
    						success:function(response){
    							store.load();
    							Ext.Msg.alert("成功","成功");
    						},
    						failure:function(response){
    							store.load();
    							Ext.Msg.alert("成功","成功");
    						}
    					});
    				

    	 
    	 }
	     	}
	 });
	var grid = new Ext.grid.GridPanel({
		//collapsible :true,
	    //split: true,
	    title:"调账商务审核",
	    height: document.documentElement.clientHeight-25,
// 	    width:2000,
	    store:store,
	    forceFit:true,
	    id:'grid',
 		selModel:Ext.create('Ext.selection.CheckboxModel',{checkOnly:false}), 
	    columnLines: true,
	    menuDisabled:true,
	    bbar: [{
			xtype: 'pagingtoolbar',
			store: store,
			displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
			emptyMsg: "没有数据",
			beforePageText: "当前页",
			afterPageText: "共{0}页",
			displayInfo: true
		}],
	     tbar: [edit,NoPass],
	    viewConfig:{enableTextSelection:true,stripeRows: true},
	    columns: [
					{text: 'ID',  dataIndex:'ID',hidden:true,maxWidth: 200},
					{text: 'COST_ID',  dataIndex:'COST_ID',hidden:true,maxWidth: 200},
					{text: '托单号',  enableColumnResize:true,dataIndex:'BILL_CODE', maxWidth: 300 ,},
					{text: '提单号',  dataIndex:'LADING_BILL_CODE',enableColumnResize:true,maxWidth: 200},
					{text: '费用板块',  dataIndex:'COST_PLATE',hidden:true,maxWidth: 200},
					{text: '结算单位', dataIndex:'SETTLEMENT_UNIT', minWidth: 80},
					{text: '费用名称',  dataIndex:'COST_NAME',maxWidth: 80},
					{text: '箱型',  dataIndex:'CONTAINER_TYPE',maxWidth: 80},
					{text: '箱量', dataIndex:'CONTAINER_NUM', maxWidth: 80},
					{text: '含税价',  dataIndex:'TAX_PRICE',maxWidth: 80},
					{text: '含税价调整',  dataIndex:'ADJUST_TAX_PRICE',maxWidth: 80},
					{text: '不含税价',  dataIndex:'NON_TAX_PRICE',maxWidth: 80},
					{text: '不含税价调整',  dataIndex:'ADJUST_NON_TAX_PRICE',maxWidth: 80},
					{text: '税率',  dataIndex:'TAX_RATE',maxWidth: 80},
					{text: '税率调整',  dataIndex:'ADJUST_TAX_RATE',maxWidth: 80},
					{text: '币种',  dataIndex:'CURRENCY',maxWidth: 80},
		
			
			],
	    renderTo:Ext.getBody(),
	});
});
</script>
</html>